<%-- 
    Document   : detail_pekerjaan
    Created on : Jul 21, 2012, 11:55:57 AM
    Author     : DarkTerror
--%>


<%@page import="entity.Alokasi"%>
<%@page import="dao.AlokasiDAOImpl"%>
<%@page import="entity.Pekerjaan"%>
<%@page import="java.util.List"%>
<%@page import="dao.PekerjaanDAOImpl"%>
<%@page import="javax.persistence.EntityManager"%>
<%@page import="additional.Help"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Detail Pekerjaan</title>

        <link href="../style/style.css" rel="stylesheet" type="text/css" /> 
        <script type="text/javascript">
            <%
                Long id_pekerjaan = Long.MIN_VALUE;
                try {
                    id_pekerjaan = Long.parseLong(request.getParameter("id"));
                } catch (Exception e) {
                    out.write("alert('ID Pekerjaan Kosong'); \n");
                    out.write("location.href='view_pekerjaan.jsp'; \n");
                }
            %>
        </script>
    </head>
    <body>
        <div id="central">
            <div id="menuatas">
                <marquee>
                    <h3> Welcome </h3>
                </marquee>
            </div>
            
            <div id="header">
                <% 
                    if(request.getSession().getAttribute("user") == null) {
                        out.write("<a href='/TR_Persistance_Alokasi_Karyawan/Logout'>LogOut</a>");
                    } else {
                        out.write("<a href='/TR_Persistance_Alokasi_Karyawan/login.jsp'>LogIn</a>");
                    }
                %> 
            </div>
            
            <ul id="navlist">
                <li><a id="n1" href="Home.jsp"><span>Home</span></a></li>
                <li><a id="n2" href="view_karyawan.jsp"><span>Karyawan</span></a></li>
                <li><a id="n3" href="view_pekerjaan.jsp"><span>Pekerjaan</span></a></li>
                <li><a id="n4" href="view_alokasi.jsp"><span>Alokasi Pekerjaan</span></a></li>                               
                <li><a id="n5" href="about.jsp"><span>About</span></a></li>                               
            </ul>
            <div id="content">                
                <div id="rightside">
                    <h1>Detail Pekerjaan Karyawan</h1>
                    <hr>
                    <table border="0" width="100%">
                        <tr>
                            <th>Nama Karyawan</th>
                            <th>Nama Pekerjaan</th>
                        </tr>

                        <%
                            try {
                                Pekerjaan p = new PekerjaanDAOImpl(Help.getEM()).get(id_pekerjaan);
                                List<Alokasi> list = new AlokasiDAOImpl(Help.getEM()).getsByPekerjaan(p);
                                for (Alokasi a : list) {
                                    out.write("<tr> \n");
                                    out.write("<td>"+a.getKaryawan().getNama() + "</td> \n");
                                    out.write("<td>"+a.getPekerjaan().getNama() + "</td> \n");
                                    out.write("</tr> \n");
                                }
                            } catch (Exception e) {
                                out.write(e.getMessage());
                            }
                        %>
                    </table>
                </div>
                <div id="footer">
                    <p>&COPY; copyright TR PERSISTENCE</p>
                </div>
                </body>
                </html>
